Skip to content

Conversation

@cawalch
Copy link
Collaborator

@cawalch cawalch commented Jul 13, 2025

Fixes issue where expressions like [?stack==''].branch[?starts_with(@, 'one')] would fail with invalid-type error.

The FilterProjection interpreter now correctly handles array-of-arrays by applying filters to sub-elements while maintaining projection structure.

Fixes #23

@cawalch cawalch self-assigned this Jul 13, 2025
Fixes issue where expressions like [?stack==''].branch[?starts_with(@, 'one')] would fail with invalid-type error.

The FilterProjection interpreter now correctly handles array-of-arrays by applying filters to sub-elements while maintaining projection structure.

Fixes #23

<!-- ps-id: 01fb2a2e-8823-477c-b9d2-1dadc433b26a -->
@cawalch cawalch force-pushed the ps/rr/fix__handle_filter_projections_with_array_field_access branch from 85798be to 45115b7 Compare July 13, 2025 20:32
@cawalch cawalch added the bug Something isn't working label Jul 13, 2025
@cawalch cawalch requested a review from springcomp July 13, 2025 20:34
@springcomp
Copy link
Contributor

I think this is controversial 😏

I spent ages trying to figure out which one is right.

It turns out that this is in fact not a bug, even though the result is not intuitive.
The root cause for the "counter-intuitive" behaviour is that a [?…] bracket-specifier actually ends a projection. So the trailing [?starts_with(@, 'one') ends the upstream projection and ends up operating on an array-of-arrays, which is not the correct type as per the specification.

Source: from the Python mother-of-all implementations :

        # Everything above stops a projection.
        'star': 20,
        'filter': 21,

I also think that the language design that led to this difference is unfortunate and should definitely be addressed.
We need to try and think about a proposal that would fix this unambiguously.

@cawalch
Copy link
Collaborator Author

cawalch commented Jul 13, 2025

I think this is controversial 😏

I spent ages trying to figure out which one is right.

It turns out that this is in fact not a bug, even though the result is not intuitive. The root cause for the "counter-intuitive" behaviour is that a [?…] bracket-specifier actually ends a projection. So the trailing [?starts_with(@, 'one') ends the upstream projection and ends up operating on an array-of-arrays, which is not the correct type as per the specification.

Source: from the Python mother-of-all implementations :

        # Everything above stops a projection.
        'star': 20,
        'filter': 21,

I also think that the language design that led to this difference is unfortunate and should definitely be addressed. We need to try and think about a proposal that would fix this unambiguously.

Potential workaround / design decision that should be documented?

Flatten operator

[?stack==''].branch[] | [?starts_with(@, 'one')]
// Result: ["one/"]

@cawalch cawalch closed this Jul 13, 2025
@cawalch cawalch deleted the ps/rr/fix__handle_filter_projections_with_array_field_access branch July 16, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with filters and projections

3 participants